<?
	include('top.php');
	include('conn.php');

	session_start();
	$msg='';
	if($_REQUEST['up']=='true' and isset($_REQUEST['id']))
	{
		$id=$_REQUEST['id'];
		$sqledit="select * from bankmast where status = 0 and bankname='".$id."'";
		include('conn.php');
		$resedit=mysql_query($sqledit);
		$rowedit=mysql_fetch_assoc($resedit);		
	}
	
	if($_REQUEST['submit']=='Save Record')
	{
		$bankname=$_REQUEST['bankname'];
		$address=$_REQUEST['address'];
		$city=$_REQUEST['city'];
		$enteredby=$_SESSION['username'];
		
		$sqlc="select count(*) cnt from bankmast where bankname='".$bankname."'";
		$resc=mysql_query($sqlc);
		$rowc=mysql_fetch_assoc($resc);
		if($rowc['cnt']==0)
		{
			$sql="insert into bankmast(bankname,address,city,enteredby,entrydt)
				values('".$bankname."','".$address."','".$city."','".$enteredby."',sysdate())";
			$res=mysql_query($sql);
			if($res)
				$msg='Record saved successfully';			
		}
		else
		{
				$msg='Record Already Exist';			
		}		
	}
?>
 <script type="text/javascript" src="bankmain.js"></script>
 <script language="javascript">
 function SearchCtrl($scope, $http) {
        $scope.url = 'savebank.php'; // The url of our search
        // The function that will be executed on button click (ng-click="search()")
        $scope.search = function() {
            // Create the http post request
            // the data holds the keywords
            // The request is a JSON request.  i want the data in $_POST
            $http.post($scope.url, { "bankname" : $scope.bankname,"address" : $scope.address,"city" : $scope.city}).
            success(function(data, status) {
                $scope.status = status;
                $scope.data = data;
                $scope.result = data; // Show result from server in our <pre></pre> element
            }).
            error(function(data, status) {
                $scope.data = data || "Request failed";
                $scope.status = status;         
            });
        };
			//alert(" ");
}
function deletebank(name0)
{
	if (confirm('Do you really want to delete this record?')) {
		$.post( "bankdelete.php?", { bankname: name0})
		.done(function( data ) {
		alert( "Record Deleted ");// + data );
		});
	}
	//var jqxhr = $.post( "customerdelete.php", function() {
	//alert( "success" );
	//})
}
function editbank(Referenceno,param2)
{
//	alert(Referenceno);
	window.location.href = Referenceno;	
}

 </script>
 <td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Admin / Bank Master</label></td>
<div  align="center">
			<div ng-controller="SearchCtrl">
			<table  cellpadding="4" id="box-table-a" cellspacing="4" border="1" width="650" bgcolor="#000000" style="background-color:#DFEBF9;">
				<tr><td colspan="3" align="center" style="text-align:center; color:#FF0000;">{{result}}</td></tr>
				<tr><td colspan="3" align="center" style="text-align:center; font-weight:bold;">Bank Master</td></tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Bank Name</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
					<input type="text" id="bankname" name="bankname" class="smallInput" value="<?=$rowedit['bankname']?>" required= "" ng-model="bankname" placeholder="Name" style="width:280px; text-align:left; font-size:12px; font-weight:bold;" />
					
<!--						<input type="text" id="bankname" name="bankname" class="smallInput"  required= "" ng-model="bankname" placeholder="Name" style="width:280px; text-align:left; font-size:12px; font-weight:bold;" /> -->
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">Address</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
					 <textarea name="address" cols="45" rows="3" class="smallInput" id="address" ng-model="address" style="font-size:12px; text-align:left; font-weight:bold;"></textarea>
					</td>
				</tr>
				<tr bgcolor="#FFFFFF">
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">City</label></td>
					<td ><label style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">:</label></td>
					<td style="text-align:left; font-size:14px; color:#333333; font-weight:bold; vertical-align:middle;">
						<input type="text" id="city" name="city" class="smallInput" required= "" ng-model="city" placeholder="City" style="width:180px; text-align:left; font-size:12px; font-weight:bold;" />
					</td>
				</tr>
				<tr>
					<td align="center" colspan="3" style="background-color:#BBE2EE">
					<button type="submit" class="btn" ng-click="search();">Save</button>
					</td>
				</tr>
			</table>
			
		</div>
			
			<div  ng-controller="bank" id="bank">
				<div> <a ng-click="refreshGrid()"> Refresh Grid </a></div>
		        <div class="gridStyle1" ng-grid="gridOptions"></div>
			</div>
</div>
</body>
</html>
